<template>
  <div>
    <!--ant 主题皮肤样式-->
    <a-config-provider
        :theme="{
          token: {
            colorPrimary: '#81d8cf',
          },
        }">
      <router-view></router-view>
      <a-back-top />
    </a-config-provider>
  </div>
</template>

<script setup>
import {watch, h, onMounted, onBeforeUnmount} from "vue";
import Pubsub from "pubsub-js";

// 滚动条监听
const handleScroll = async () => {
  const scrollPosition = Math.floor(document.documentElement.scrollTop);
  const windowHeight = window.innerHeight;
  const scrollHeight = document.documentElement.scrollHeight;
  if (scrollPosition + windowHeight >= scrollHeight - 50) {
    Pubsub.publish('scroll', {
      msg: '滚动到底了'
    });
  }
};

onMounted(() => {
  window.addEventListener('scroll', handleScroll);
});

onBeforeUnmount(() => {
  window.removeEventListener('scroll', handleScroll);
});
</script>

